<!DOCTYPE html>
<meta charset="utf-8" />
<style type="text/css">
.table-header {
    background-color: #46A3FF;
    color: #fff;
    font-size: 14px;
    line-height: 38px;
    margin-bottom: 1px;
    padding-left: 12px;
}

</style>
<div class="rowt" >
	<div class="col-xs-12">
		<div>
			<table id="sample-table-1" class="table table-striped table-bordered table-hover" >
				<thead>
					<tr>
						<th class="center">
							<label class="position-relative">
								<input type="checkbox" class="ace" id="checkboxlbl1"/>
								<span class="lbl"></span>
							</label>
						</th>
						<th width="100px">合作商编号</th>
						<th width="200px">合作商名称</th>
						<th width="100px">分润计算日期</th>
						<th width="50px">等级</th>
						<th width="100px">分润总金额</th>
						<th width="100px">分润状态</th>
						<th width="100px">支付订单号</th>
						<th width="100px">交易金额</th>
						<th width="100px">交易费率</th>
						<th width="100px">交易手续费</th>
						<th width="100px">合作商费率</th>
						<th width="100px">合作商手续费</th>
						<th width="100px">合作商分润比</th>
					</tr>
				</thead>

				<tbody id="mybody1">
				</tbody>
			
			</table>
		</div>
		<ul class="pagination pull-left no-margin" id="paging_bar_Count"></ul>
		<ul class="pagination pull-right no-margin" id="paging_bar_1"></ul>
	</div>
</div>

<script type="text/javascript">
	var pageSize=7;
	var bodycp1=0;
	$(document).ready(function() {
		$("#checkboxlbl1").change(function(){  
			var is_checked =$("#checkboxlbl1").is(":checked");
			$("input[name='mybody1paging_bar_1']").each(function(){
				this.checked=is_checked;
			}); 
		});
		getjson("mpamng/agent/queryProfitSharingDetail.do",1,"mybody1","paging_bar_1");
	});

	function getjson(url,cp,body,bar){
		var dialog=$("#dlg-profitSharingDetail").Dialog();
		 $.ajax({
			 type:"post",
			 dataType:"json",
			 url:url,
			 data: {pageSize:pageSize,currentPages:cp,agentId:dialog.pageParam.agentId,sharDate:dialog.pageParam.sharDate},
			 success : function(result) {
					if (result.rspcod != 200) {
						msg.alert("错误", result.rspmsg + " 错误代码："+ result.rspcod, 'error');
					} else {
						if(bodycp1!=0){
							$("#"+body+" tr").remove();
							$("#"+bar+" a").remove();
							$("#paging_bar_Count li").remove();
						}
						
						var paging_bar_Count ='<li><a href="javascript:void(0)">分润总金额:'+cent2Yuan(result.obj.sharamtcount)+' 元</a>';
						 paging_bar_Count +='<li><a href="javascript:void(0)">交易总金额:'+cent2Yuan(result.obj.payamtcount)+' 元</a>';
						 paging_bar_Count +='<li><a href="javascript:void(0)">交易总手续费:'+cent2Yuan(result.obj.payfeecount)+' 元</a>';
						$("#paging_bar_Count").append(paging_bar_Count);
						
						var pagecount = Math.ceil(result.records/pageSize);
						
						var paging_bar='<li><a href="javascript:void(0)">共 '+result.records+' 条</a>';
						
						paging_bar+='<li class="prev '+(cp<=1?'disabled':'')+'"><a href="javascript:void(0)" onclick=\'getjson(\"'+url+'\",1,\"'+body+'\",\"'+bar+'\");\'>首页</a>';
						for(var i=1;i<=pagecount;i++){
							paging_bar+='<li class="'+(cp==i?'active':'')+'"><a href="javascript:void(0)" onclick=\'getjson(\"'+url+'\",'+i+',\"'+body+'\",\"'+bar+'\");\'>'+i+'</a>';
						}
						paging_bar+='<li class="next '+(cp==pagecount||pagecount==0?'disabled':'')+'"><a href="javascript:void(0)" onclick=\'getjson(\"'+url+'\",'+pagecount+',\"'+body+'\",\"'+bar+'\");\'>尾页</a>';
						$("#"+bar).append(paging_bar);
						
						if(result.rows==null||result.rows=='null'){
							return false;
						}
						$.each(result.rows,function(index,obj){
							var tr ='<tr><td class="center"><label class="position-relative"><input value="'+obj.agentId+'" type="checkbox" name="'+(body+bar)+'" class="ace"  /><span class="lbl"></span></label></td>'
							+'<td>'+obj.agentId+'</td>'+'<td>'+obj.agentName+'</td>'+'<td>'+obj.sharDate+'</td>'+'<td>'+obj.agentDgr+'</td>'+'<td>'+cent2Yuan(obj.sharamt)+'</td>'
							+'<td>'+DICT.get('SHAR_STATUS',obj.sharStatus)+'</td>'+'<td>'+obj.payNo+'</td>'+'<td>'+cent2Yuan(obj.payAmt)+'</td>'+'<td>'+obj.payRate+'</td>'+'<td>'+cent2Yuan(obj.payFee)+'</td>'
							+'<td>'+obj.agentRate+'</td>'+'<td>'+cent2Yuan(obj.agentFee)+'</td>'+'<td>'+obj.sharProfitRatio+'</td>'
							$("#"+body).append(tr);
						});
						bodycp1=cp;
					}
				},
			 error : function(XMLHttpRequest, textStatus) {
					msg.alert("错误", "错误代码：" + XMLHttpRequest.status + ",错误描述："+ textStatus, 'error');
				}
		 });
	}
  
</script>